import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_yn_goods/config/app_translations.dart';
import 'package:flutter_yn_goods/utils/loading/loading_utils.dart';
import 'package:get/get.dart';

import 'launcher_logic.dart';

class LauncherPage extends StatelessWidget {
  final logic = Get.put(LauncherLogic());

  @override
  Widget build(BuildContext context) {
    return PopScope(
      canPop: false,
      onPopInvoked: (bool? didPop) {
        if (didPop == true) {
          return;
        }
        int now = DateTime.now().millisecondsSinceEpoch;
        if (now - logic.lastPopTime > 3000) {
          logic.lastPopTime = now;
          LoadingUtils.showToast(LocaleKeys.press_again_to_exit.tr,);

        } else {
          logic.lastPopTime = 0;
          SystemChannels.platform.invokeMethod('SystemNavigator.pop');
        }
      },
      child:  Scaffold(
        body: Center(
          child: Text(LocaleKeys.initializing.tr),
        ),
      ),
    );
  }
}
